<?php
    include_once('Configs/database.php');
    include_once('Models/ThoiKhoaBieu.php');
    $malophp = $_GET['malophp'];
    $siso = $_GET['siso'];
    //$malophp = $_POST['hidmalophp'];
    //$siso = $_POST['hidsiso'];
    //$malophp = $_POST['txtmalophp'];
    //$siso = $_POST['txtsiso'];
?>
<script src="Libraries/js/js.js"></script>
<script language="javascript">
    function getValue(id){
        for(var i=0;i<document.capnhattkb.cbothu.length;i++){
    		if(document.capnhattkb.cbothu[i].value==document.getElementById("thu" + id).innerHTML){
    			document.capnhattkb.cbothu.selectedIndex=i;
    		}
	   }
       for(var i=0;i<document.capnhattkb.cbotietbd.length;i++){
    		if(document.capnhattkb.cbotietbd[i].value==document.getElementById("tietbd" + id).innerHTML){
    			document.capnhattkb.cbotietbd.selectedIndex=i;
    		}
	   }
       for(var i=0;i<document.capnhattkb.cbosotiet.length;i++){
    		if(document.capnhattkb.cbosotiet[i].value==document.getElementById("sotiet" + id).innerHTML){
    			document.capnhattkb.cbosotiet.selectedIndex=i;
    		}
	   }
       //document.capnhattkb.cbomaphong[0].value = document.getElementById("maphong" + id).innerHTML);
       //xepPhong(document.capnhattkb.txtsiso.value,document.capnhattkb.cbothu.value,document.capnhattkb.cbotietbd.value,document.capnhattkb.cbosotiet.value);
       /*for(var i=0;i<document.capnhattkb.cbomaphong.length;i++){
    		if(document.capnhattkb.cbomaphong[i].value==document.getElementById("maphong" + id).innerHTML){
    			document.capnhattkb.cbomaphong.selectedIndex=i;
    		}
	   }*/
    }
</script>
<form name="capnhattkb" method="POST">
<table align="center" class="font" width="450" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="main_1"><img border="0" src="Libraries/images/tbl_left.gif" width="10" height="25" /></td>
    <td align="center" class="main_1">C&#7853;p Nh&#7853;t Th&#7901;i Kh&oacute;a Bi&#7875;u </td>
    <td class="main_1"><p align="right"><img border="0" src="Libraries/images/tbl_right.gif" width="10" height="25" /></p></td>
  </tr>
  <tr bgcolor="#dae9f3">
    <td class="border_1" colspan="3" valign="top"><table width="100%" border="0" align="center">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td><a href="#"></a></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>M&atilde; l&#7899;p </td>
        <td><input name="txtmalophp" type="text" value="<?php echo $malophp?>"  size="15" readonly="true"/></td>
        <?php 
            /*if (isset($_POST['txtmalophp'])){
                echo "<script language='javascript'>document.capnhattkb.txtmalophp.value='$malophp';</script>";
            }*/
        ?>
        <td>Sĩ số </td>
        <td><input name="txtsiso" type="text" value="<?php echo $siso?>" size="5" readonly="true"/></td>
        <?php 
            /*if (isset($_POST['txtsiso'])){
                echo "<script language='javascript'>document.capnhattkb.txtsiso.value='$siso';</script>";
            }*/
        ?>
        <td>Th&#7913;</td>
        <td>
			<select name="cbothu">
                <option value="0"></option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">CN</option>
        	</select>
		</td>
      </tr>
      <tr>
        <td>Ti&#7871;t B&#272; </td>
        <td>
            <select name="cbotietbd">
                <option value="0"></option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
            </select>
        </td>
        <td>S&#7889; ti&#7871;t </td>
        <td>
            <select name="cbosotiet" onchange="xepPhong(document.capnhattkb.txtsiso.value,document.capnhattkb.cbothu.value,document.capnhattkb.cbotietbd.value,this.value);">
                <option value="0"></option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
            </select>
        </td>
        <td>Ph&ograve;ng</td>
        <td>
			<div id="maphong">
                <select name="cbomaphong">
                    <option value=" "></option>
                </select>
            </div>		
        </td>
      </tr>
      <tr>
        <td colspan="6" align="center"><span class="main_3">
          <input name="btnthem" type="submit" class="button_1" id="btnthem" value="Thêm"/>
          <input name="btnxoa" type="submit"  class="button_1" id="btnxoa" value="Xóa"/>
          <input name="btntrove" type="button"  class="button_1" id="btntrove" value="Trở về" onclick="history.go(-1)"/>
        </span></td>
      </tr>
      
    </table></td>
  </tr>
</table>
<br />
<br />
<table align="center" class="font" width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="main_1"><img border="0" src="Libraries/images/tbl_left.gif" width="10" height="25" /></td>
    <td align="center" class="main_1">Thời Khóa Biểu </td>
    <td class="main_1"><p align="right"><img border="0" src="Libraries/images/tbl_right.gif" width="10" height="25" /></p></td>
  </tr>
  <tr >
    <td class="border_1" colspan="3" valign="top"><table width="400" class="border_1" style="border:none" id="tbmain" cellpadding="0" cellspacing="0">
        <?php
             $tkb = new ThoiKhoaBieu();
             $tkb->setMaLopHP($malophp);
             $resulttkb = $tkb->thoiKhoaBieuLopHP();
             $numtkb = mysql_num_rows($resulttkb);
             if ($numtkb > 0){ $i = 0;
        ?>
                  <tr>
                    <td align="center" width="30" class="main_3" >Thứ</td>
                    <td align="center" class="main_3" width="60">Ti&#7871;t B&#272; </td>
                    <td align="center" class="main_3" width="60">S&#7889; Ti&#7871;t </td>
                    <td align="center" class="main_3" width="60">Ph&ograve;ng</td>
                    <td align="center" class="main_3" width="50">Ch&#7885;n</td>
                  </tr>
                  <?php
                        
                  while ($rowstkb = mysql_fetch_array($resulttkb)){
                        $i++;
                        $ci = 2 - $i % 2;
                       echo "<tr>";
                           echo "<td align='center' class='level_1_$ci'><div id='thu$i'>".$rowstkb['thu']."</div></td>";
                           echo "<td width='60' align='center' class='level_1_$ci'><div id='tietbd$i'>".$rowstkb['tietbd']."</div></td>";
                           echo "<td width='60' align='center' class='level_1_$ci'><div id='sotiet$i'>".$rowstkb['sotiet']."</div></td>";
                           echo "<td width='60' align='center' class='level_1_$ci'><div id='maphong$i'>".$rowstkb['maphong']."</div></td>";
                           echo "<td align='center' class='level_1_$ci'><input type='radio' name='chkchon' value='$i'  onclick='getValue(this.value);'></td>";
                      echo "</tr>";
                  }
            }
            else{
                echo "<tr>";
                    echo "<td width='30' align='center' colspan='5'><b>Chưa sắp Thời khóa biểu</b></td>";
                                                
                                                
                echo "</tr>";
            }
      ?>
    </table></td>
  </tr>
</table>
</form>